/*
 *	Copyright (C) 2008 - Mauricio Bieze Stefani
 *	This file is part of the Insano Game Engine.
 *
 *	Insano is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *	Insano is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with Insano.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "Animation.h"

AnimationMD2::AnimationMD2()
{
	actions[STAND]=irr::scene::EMAT_STAND;
	actions[WALK]=irr::scene::EMAT_RUN;
	actions[RUN]=irr::scene::EMAT_RUN;
	actions[ATTACK]=irr::scene::EMAT_ATTACK;
	actions[PAIN_A]=irr::scene::EMAT_PAIN_A;
	actions[PAIN_B]=irr::scene::EMAT_PAIN_B;
	actions[PAIN_C]=irr::scene::EMAT_PAIN_C;
	actions[JUMP]=irr::scene::EMAT_JUMP;
	actions[FLIP]=irr::scene::EMAT_FLIP;
	actions[SALUTE]=irr::scene::EMAT_SALUTE;
	actions[FALLBACK]=irr::scene::EMAT_FALLBACK;
	actions[WAVE]=irr::scene::EMAT_WAVE;
	actions[POINT]=irr::scene::EMAT_POINT;
	actions[CROUCH_STAND]=irr::scene::EMAT_CROUCH_STAND;
	actions[CROUCH_WALK]=irr::scene::EMAT_CROUCH_WALK;
	actions[CROUCH_ATTACK]=irr::scene::EMAT_CROUCH_ATTACK;
	actions[CROUCH_PAIN]=irr::scene::EMAT_CROUCH_PAIN;
	actions[CROUCH_DEATH]=irr::scene::EMAT_CROUCH_DEATH;
	actions[DEATH_FALLBACK]=irr::scene::EMAT_DEATH_FALLBACK;
	actions[DEATH_FALLFORWARD]=irr::scene::EMAT_DEATH_FALLFORWARD;
	actions[DEATH_FALLBACKSLOW]=irr::scene::EMAT_DEATH_FALLBACKSLOW;
	actions[BOOM]=irr::scene::EMAT_BOOM;
}

void AnimationMD2::setAction(irr::scene::IAnimatedMeshSceneNode* node, Actions newAction)
{
	node->setMD2Animation(actions[newAction]);
}

void AnimationFrame::setAction(irr::scene::IAnimatedMeshSceneNode* node, Actions newAction)
{
	irr::core::vector2di& range=actions[newAction];
	node->setFrameLoop(range.X, range.Y);
}

void AnimationFrame::addAction(Actions action, irr::s32 startFrame, irr::s32 endFrame)
{
	actions[action]=irr::core::vector2di(startFrame, endFrame);
}
